package test;

import handlers.echo.EchoHandler;
import handlers.echo.EchoHandlerByteChunk;
import handlers.echo.EchoHandlerByteClose;
import handlers.echo.InMemoryKeyValueStoreHandler;
import handlers.echo.ProxyHandler;

import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;

import org.junit.Test;

import server.IterativeSocketServer;
import thread.ConcurrentSocketServer;
import thread.ProxyTCPConcurrentServer;

public class practica1 {

	@Test
	public void e1() {
		try {
			new IterativeSocketServer(20007, InetAddress.getByName("localhost"),
					new EchoHandlerByteChunk());
		} catch (final Exception e) {
			System.out.println("Ocurrio un error");
			e.printStackTrace();
		}
	}

	@Test
	public void e2() {
		try {
			new IterativeSocketServer(20007, InetAddress.getByName("localhost"),
					new EchoHandlerByteClose());
		} catch (final Exception e) {
			System.out.println("Ocurrio un error");
			e.printStackTrace();
		}
	}

	@Test
	public void e5() {
		try {
			System.out.println("SERVIDOR ECHO CONCURRENTE");
			new ConcurrentSocketServer(20007, InetAddress.getByName("localhost"),
					new EchoHandler());
		} catch (final Exception e) {
			e.printStackTrace();
		}
	}
	
	@Test
	public void e8() {
		try {
			System.out.println("CLIENTE URL");
			new TCPURLClient("www.google.com.ar");
		} catch (final Exception e) {
			e.printStackTrace();
		}
	}
	
	@Test
	public void e10() {
		try {
			System.out.println("SERVIDOR PROXY CONCURRENTE");
			new ProxyTCPConcurrentServer(20008, InetAddress.getByName("localhost"),
					20007, "127.0.0.1", new ProxyHandler());
		} catch (final Exception e) {
			System.out.println("Ocurrio un error");
			e.printStackTrace();
		}
	}
	
	@Test
	public void e11() {
		try {
			System.out.println("E.11) IN-MEMORY KEY-VALUE STORE");
			new ConcurrentSocketServer(20011, InetAddress.getByName("localhost"),
					new InMemoryKeyValueStoreHandler());
		} catch (UnknownHostException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			System.out.println("Termina servidor");
		}
	}



}
